home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2366 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  37 lines

  1. Path: news.eunet.fi!fipnet!kone!jsaarinen
  2. Newsgroups: comp.sys.amiga.programmer
  3. X-NewsReader: IntuiNews 1.2b (31.7.94)
  4. References: <310CC190.78DF@gih.no>
  5. From: "Jyrki Saarinen" <jsaarinen@kone.fipnet.fi>
  6. Date: Tue, 30 Jan 96 14:15:08 UT
  7. Comments: Illegal date header - new date added by quicknews
  8. X-Original-Date: Tue, 30 Jan 96 09:23:50 
  9. MIME-Version: 1.0
  10. Content-Type: text/plain; charset=iso-8859-1
  11. Content-Transfer-Encoding: binary
  12. Subject: Re: NormalVectors-How to compare angles?
  13. Message-ID: <38232221@kone.fipnet.fi>
  14.  
  15.  
  16. > I'm trying to do gouroud shading in assem, and I need a fast way of
  17. > comparing the vectors, so I can calculate the colors. Is there a faster
  18. > way of doing this then using normalvectors and comparing them to the 
  19. >ávector from the lightsource (angles between vectors are a shitty job to do 
  20. > (roots and sines) especially in asm). I can fake it if all the surfaces 
  21. >áare the same size, but thats not what I want to do...
  22.  
  23. Use unit vectors, so that your normal vectors lenght is 1.
  24. Because of that, the dot product becomes:
  25.  
  26. cos(a,b) = ax*bx + ay*by + az*bz
  27.  
  28. Instead of:
  29.  
  30. cos(a,b) = ax*bx + ay*by + az*bz
  31.            ---------------------
  32.      sqrt(ax*ax+ay+ay*az*az)*sqrt(bx*bx+by+by*bz*bz)
  33.      
  34. --                               _
  35. a Stellar programmer          _ //
  36. "Amiga - back for the future" \X/
  37.